package com.anycc.cloud.core.dto;

import com.anycc.cloud.core.entity.Account;
import com.anycc.cloud.core.entity.Role;
import com.anycc.cloud.core.enums.Status;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * account dto for userDetail of auth model
 */
@Data
public class AccountDto {
    private String userId;//account id
    private String username;//account username
    private String password;// account password
    private Integer status;//account status
    private List<String> roleStringList;

    public AccountDto() {

    }

    public AccountDto(Account account) {
        this.userId = account.getId();
        this.username = account.getUsername();
        this.password = account.getPassword();
        this.status = account.getStatus().equals(Status.ENABLE) ? 1 : 0;
        this.roleStringList = account.getRoles().stream().map(Role::getSn).collect(Collectors.toList());
    }

}
